﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using G.Navigate;

namespace FY13.View
{
    public partial class Index : GBasePage
    {
        public Index()
        {
            InitializeComponent();
        }
        Data.UserInfo user;
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (e.NavigationMode == System.Windows.Navigation.NavigationMode.New)
            {
                var list = this.NavigationService.BackStack.ToArray();
                foreach (var item in list)
                {
                    this.NavigationService.RemoveBackEntry();
                }
            }
            string email = this.NavigationContext.QueryString["userid"];
            user = GloabalData.Instance.FYDataBase.Users.First(c => c.Email == email);
        }

        private void listbox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            switch (listbox1.SelectedIndex)
            {
                case 0:
                    this.NavigationService.Navigate("/View/AgendaPage.xaml");
                    break;
                //case 1:
                //    GloabalData.GoUserInfo();
                //    break;
                case 1:
                    this.NavigationService.Navigate("/View/HotelInfoPage.xaml");
                    break;
                case 2:
                    this.NavigationService.Navigate("/View/AttentionPage.xaml");
                    break;
                case 3:
                    this.NavigationService.Navigate("/View/AboutPage.xaml");
                    break;
                case 4:
                    this.NavigationService.Navigate("/View/MapPage.xaml");
                    break;
                case 5:
                    this.NavigationService.Navigate("/View/ContactsPage.xaml");
                    break;
                case 6:
                    this.NavigationService.Navigate("/View/ReminderPage.xaml");
                    break;
                default:
                    break;
            }
            listbox1.SelectedIndex = -1;
        }

        private void btnBack_Click(object sender, EventArgs e)
        {
            this.GoBack();
        }

        private void btnMy_Click(object sender, EventArgs e)
        {
            GloabalData.GoUserInfo();
        }

        private void menuLogout_Click(object sender, EventArgs e)
        {
            GloabalData.Instance.AutoLoginId = null;
            this.NavigationService.Navigate("/MainPage.xaml");
        }
    }
}